package com.its.oa.system.module.service.impl;

import java.util.List;

import com.its.oa.model.Module;
import com.its.oa.model.Role;
import com.its.oa.system.module.dao.ModuleDao;
import com.its.oa.system.module.service.ModuleService;
import com.its.oa.util.EntityValidata;

public class ModuleServiceImpl implements
		ModuleService {
	private ModuleDao moduleDao;
	
	public void setModuleDao(ModuleDao moduleDao) {
		this.moduleDao = moduleDao;
	}

	public String addModule(Module parentModule, String name, String code) {
		// TODO Auto-generated method stub
		return null;
	}

	public String delModule(Module module) {
		// TODO Auto-generated method stub
		return null;
	}

	public Module findModuleByCode(String code) {
		// TODO Auto-generated method stub
		return null;
	}

	public List<Module> findModuleByName(String name) {
		// TODO Auto-generated method stub
		return null;
	}

	public List<Module> findModuleListByCode(String code) {
		// TODO Auto-generated method stub
		return null;
	}

	public List<Module> getModuleList() {
		List<Module> list = moduleDao.findAll();
		if(EntityValidata.isNotEmpty(list))
			return list;
		else
			return null;
	}

	public String updateModule(Module module) {
		// TODO Auto-generated method stub
		return null;
	}
	public String findUrlSByRoleList(List<Role> roleList){
		String urls = "";
		List<Module> list = moduleDao.findModulesByRoles(roleList);
		for (Module module : list) {
			urls += urls.length()>0?","+module.getPath():module.getPath();
		}
		return urls;
	}

	public List<Module> getModuleListByPage(int offset, int pagesize) {
		return moduleDao.findAllByPage(offset, pagesize);
	}
}
